﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace WpfApp_Binding.DataValidation
{
    public class AddressValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            string _value = value?.ToString() ?? "";
            if (string.IsNullOrEmpty(_value))
                return new ValidationResult(false, "请输入地址！");
            if (_value.Trim().Length > 20)
                return new ValidationResult(false, "地址超过20个字符！");
            return new ValidationResult(true, string.Empty);
        }
    }
}
